package com.itheima.tanhua.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.tanhua.entity.UserInfo;
import com.itheima.tanhua.vo.YearItem;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Wang.XL
 */
@Mapper
public interface UserInfoMapper extends BaseMapper<UserInfo> {


    /**
     *
     * @param clunme
     * @return
     */
    @Select("SELECT ${clunme} FROM `tb_user_info` GROUP BY ${clunme}")
    List<String> getClunme(String clunme);


    /**
     *
     * @param clunme
     * @param propery
     * @return
     */
    @Select("SELECT COUNT(${clunme}) FROM `tb_user_info` WHERE ${clunme} = #{propery} ")
    int getClunmeCount(String clunme, String propery);

    /**
     * 得到年龄段的数量
     * @param min
     * @param max
     * @param clunme
     * @return
     */
    @Select("SELECT COUNT(#{clunme}) FROM `tb_user_info` WHERE age > #{min} AND age < #{max} ")
    int ageDistribution(int min, int max, String clunme);

    /**
     * 得到所有城市名称
     * @param clunme
     * @return
     */
    @Select("SELECT ${clunme} FROM `tb_user_info`")
    List<String> getArea(String clunme);
}
